package com.zhuwhao.sample;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tomergoldst.tooltips.ToolTip;
import com.tomergoldst.tooltips.ToolTipsManager;
import com.zhuwhao.sample.utils.AppUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TestActivity extends BaseActivity implements ToolTipsManager.TipListener {

    @BindView(R.id.rootLayout)
    RelativeLayout rootLayout;

    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @BindView(R.id.textMessage)
    TextView textMessage;

    private ToolTipsManager toolTipsManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        toolbar.setTitle(R.string.test);
        setSupportActionBar(toolbar);

        toolTipsManager = new ToolTipsManager(this);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

        //This must be called after the layout has been drawn You can override the 'onWindowFocusChanged()' of an Activity and show there.
        ToolTip.Builder builder = new ToolTip.Builder(this, textMessage, rootLayout, "Tip message", ToolTip.POSITION_RIGHT_TO);
        toolTipsManager.show(builder.build());
    }

    @Override
    public void onTipDismissed(View view, int anchorViewId, boolean byUser) {
        AppUtils.showToast(this, "onTipDismissed");
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @OnClick(R.id.textMessage)
    public void onViewClicked() {

    }
}
